#include <iostream>
#include "polygon.h"
#include "compose.h"
#include <map>
using namespace std;

vector<polygon> compose::allPolygon;
vector<rectangle> compose::allRectangle;
int main()
{

    polygon t_1=polygon();
    polygon t_2=polygon();
    polygon t_3=polygon();
    polygon t_4=polygon();
    polygon t_5=polygon();
    polygon t_6=polygon();

    t_1.allVertrx.push_back(pos(230,174));
    t_1.allVertrx.push_back(pos(233,174));
    t_1.allVertrx.push_back(pos(233,163));
    t_1.allVertrx.push_back(pos(230,163));
    t_1.allVertrx.push_back(pos(230,167));
    t_1.allVertrx.push_back(pos(228,167));
    t_1.allVertrx.push_back(pos(228,169));
    t_1.allVertrx.push_back(pos(230,169));

    t_2.allVertrx.push_back(pos(0,0));
    t_2.allVertrx.push_back(pos(5,0));
    t_2.allVertrx.push_back(pos(5,2));
    t_2.allVertrx.push_back(pos(3,2));
    t_2.allVertrx.push_back(pos(3,3));
    t_2.allVertrx.push_back(pos(2,3));
    t_2.allVertrx.push_back(pos(2,1));
    t_2.allVertrx.push_back(pos(0,1));

    t_3.allVertrx.push_back(pos(0,0));
    t_3.allVertrx.push_back(pos(5,0));
    t_3.allVertrx.push_back(pos(5,1));
    t_3.allVertrx.push_back(pos(4,1));
    t_3.allVertrx.push_back(pos(4,2));
    t_3.allVertrx.push_back(pos(3,2));
    t_3.allVertrx.push_back(pos(3,3));
    t_3.allVertrx.push_back(pos(0,3));


    t_4.allVertrx.push_back(pos(0,0));
    t_4.allVertrx.push_back(pos(5,0));
    t_4.allVertrx.push_back(pos(5,2));
    t_4.allVertrx.push_back(pos(3,2));
    t_4.allVertrx.push_back(pos(3,3));
    t_4.allVertrx.push_back(pos(2,3));
    t_4.allVertrx.push_back(pos(2,1));
    t_4.allVertrx.push_back(pos(0,1));

    t_5.allVertrx.push_back(pos(230,174));
    t_5.allVertrx.push_back(pos(233,174));
    t_5.allVertrx.push_back(pos(233,163));
    t_5.allVertrx.push_back(pos(230,163));
    t_5.allVertrx.push_back(pos(230,167));
    t_5.allVertrx.push_back(pos(228,167));
    t_5.allVertrx.push_back(pos(228,169));
    t_5.allVertrx.push_back(pos(230,169));

    t_6.allVertrx.push_back(pos(0,0));
    t_6.allVertrx.push_back(pos(5,0));
    t_6.allVertrx.push_back(pos(5,1));
    t_6.allVertrx.push_back(pos(3,1));
    t_6.allVertrx.push_back(pos(3,3));
    t_6.allVertrx.push_back(pos(0,3));

    t_1.init_allVertrx.push_back(pos(230,174));
    t_1.init_allVertrx.push_back(pos(233,174));
    t_1.init_allVertrx.push_back(pos(233,163));
    t_1.init_allVertrx.push_back(pos(230,163));
    t_1.init_allVertrx.push_back(pos(230,167));
    t_1.init_allVertrx.push_back(pos(228,167));
    t_1.init_allVertrx.push_back(pos(228,169));
    t_1.init_allVertrx.push_back(pos(230,169));

    t_2.init_allVertrx.push_back(pos(0,0));
    t_2.init_allVertrx.push_back(pos(5,0));
    t_2.init_allVertrx.push_back(pos(5,2));
    t_2.init_allVertrx.push_back(pos(3,2));
    t_2.init_allVertrx.push_back(pos(3,3));
    t_2.init_allVertrx.push_back(pos(2,3));
    t_2.init_allVertrx.push_back(pos(2,1));
    t_2.init_allVertrx.push_back(pos(0,1));

    t_3.init_allVertrx.push_back(pos(0,0));
    t_3.init_allVertrx.push_back(pos(5,0));
    t_3.init_allVertrx.push_back(pos(5,1));
    t_3.init_allVertrx.push_back(pos(4,1));
    t_3.init_allVertrx.push_back(pos(4,2));
    t_3.init_allVertrx.push_back(pos(3,2));
    t_3.init_allVertrx.push_back(pos(3,3));
    t_3.init_allVertrx.push_back(pos(0,3));


    t_4.init_allVertrx.push_back(pos(0,0));
    t_4.init_allVertrx.push_back(pos(5,0));
    t_4.init_allVertrx.push_back(pos(5,2));
    t_4.init_allVertrx.push_back(pos(3,2));
    t_4.init_allVertrx.push_back(pos(3,3));
    t_4.init_allVertrx.push_back(pos(2,3));
    t_4.init_allVertrx.push_back(pos(2,1));
    t_4.init_allVertrx.push_back(pos(0,1));

    t_5.init_allVertrx.push_back(pos(230,174));
    t_5.init_allVertrx.push_back(pos(233,174));
    t_5.init_allVertrx.push_back(pos(233,163));
    t_5.init_allVertrx.push_back(pos(230,163));
    t_5.init_allVertrx.push_back(pos(230,167));
    t_5.init_allVertrx.push_back(pos(228,167));
    t_5.init_allVertrx.push_back(pos(228,169));
    t_5.init_allVertrx.push_back(pos(230,169));

    t_6.init_allVertrx.push_back(pos(0,0));
    t_6.init_allVertrx.push_back(pos(5,0));
    t_6.init_allVertrx.push_back(pos(5,1));
    t_6.init_allVertrx.push_back(pos(3,1));
    t_6.init_allVertrx.push_back(pos(3,3));
    t_6.init_allVertrx.push_back(pos(0,3));



    rectangle t_r_1=rectangle(0,0,1,1);
    rectangle t_r_2=rectangle(0,0,3,2);

    compose::allRectangle.push_back(t_r_1);
    compose::allRectangle.push_back(t_r_2);
    compose::allRectangle.push_back(t_r_1);
    compose::allRectangle.push_back(t_r_2);
    compose::allRectangle.push_back(t_r_1);
    compose::allRectangle.push_back(t_r_2);
    compose::allRectangle.push_back(t_r_1);
    compose::allRectangle.push_back(t_r_2);
    compose::allRectangle.push_back(t_r_1);
    compose::allRectangle.push_back(t_r_2);
    compose::allRectangle.push_back(t_r_1);
    compose::allRectangle.push_back(t_r_2);
    compose::allRectangle.push_back(t_r_1);
    compose::allRectangle.push_back(t_r_2);

    compose::allPolygon.push_back(t_1);
    compose::allPolygon.push_back(t_5);
    compose::allPolygon.push_back(t_4);
    compose::allPolygon.push_back(t_2);
    compose::allPolygon.push_back(t_3);
    compose::allPolygon.push_back(t_6);
    compose::allPolygon.push_back(t_6);
/*
    polygon::std_pos_vec(t_1.init_allVertrx);
    polygon::std_pos_vec(t_2.allVertrx);
    */
    t_3.toRepr2();
    t_3.get_blank_Repr();
    t_6.toRepr2();
    t_6.get_blank_Repr();

        //random_shuffle(compose::allPolygon.begin(),compose::allPolygon.end());
    vector<Assembled_rec> test_result=compose::testCompose();


    compose::insert_rectangles(test_result);

    vector<rectangle*> test_rec;
    for(Assembled_rec& temp:test_result){
        test_rec.push_back(&temp);
    }
    fstream write=fstream("D:/gitee_projects/test.txt",ios::out);

    if(!write.good()){
        cout<<"2";
    }
    for(int i=0;i<test_rec.size();i++){
        test_rec[i]->write_file(write);
    }
    write.close();
    cout<<1;
    //for(int i=0;i<test_result.size();i++){
     //   test_result[i].x1;
    //}
/*
    polygon::std_pos_vec(t_1.allVertrx);
    for(int i=0;i<t_1.allVertrx.size();i++){
        cout<<"("<<t_1.allVertrx[i].x<<","<<t_1.allVertrx[i].y<<")"<<endl;
    }
    cout<<endl;
    compose::clockwise_rotation_90(pos(0,0),t_1.allVertrx);
    for(int i=0;i<t_1.allVertrx.size();i++){
        cout<<"("<<t_1.allVertrx[i].x<<","<<t_1.allVertrx[i].y<<")"<<endl;
    }
    cout<<endl;
    */


/*
    vector<combin_index> t_1;
    vector<vector<combin_index>> allgroups;
    compose::getgroups(allgroups,t_1,8);

    for(int i=0;i<t_1.size();i++){
        for(int j=0;j<t_1[i].size();j++){
            for(int q=0;q<t_1[i][j].size();q++){
                cout<<t_1[i][j][q]<<" ";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    */
}
